<template>
  <div class="pools-wrap">
    <nav>
      <Row :gutter="['48', '12']" style="display: flex">
        <Col :span="8">
          <div class="p_title">Pool</div>
        </Col>
        <Col :span="3">
          <div class="p_title">APY</div>
        </Col>
        <Col :span="5">
          <div class="p_title">Yield</div>
        </Col>
        <Col :span="4">
          <div class="p_title">Leverage</div>
        </Col>
        <Col :span="4">
          <div class="p_title"></div>
        </Col>
      </Row>
    </nav>
    <content>
      <Row :gutter="['48', '12']" style="display: flex">
        <Col class="row" :span="8" style="min-height: 122px">
          <div class="pool_col">
            <div class="p_left">
              <img class="img1" src="@/assets/icons/coin-3.png" />
              <img class="img2" src="@/assets/icons/coin-4.png" />
            </div>
            <div class="p_right">
              <div class="p_text">
                <div>Swap</div>
                <span>New</span>
              </div>
              <div class="p_tip">SPL-AAA</div>
            </div>
          </div>
        </Col>
        <Col class="row" :span="3">
          <div v-if="wallet.connected" class="apy_col">
            <span class="span">72.36%</span>
            <label class="label">22.46%</label>
          </div>
        </Col>
        <Col class="row" :span="5">
          <div v-if="wallet.connected" class="yield_col">
            <div v-for="(item, i) in pools" :key="i" class="pool_item">
              <label>{{ item.name }}</label>
              <span :class="item.className ? item.className : 'right'">{{ item.value }}</span>
            </div>
          </div>
        </Col>
        <Col class="row" :span="4">
          <div v-if="wallet.connected" class="mult_col">Multiple：<span class="mult_span">1.00</span></div>
        </Col>
        <Col class="row" :span="4">
          <div v-if="wallet.connected" class="btn-ops">
            <!-- <div class="btn-min-plus">
              <Icon type="plus" />
              <input maxLength="12" type="number" value="1.00" />
              <Icon type="minus" />
            </div> -->
            <div class="btn-1 btn-custom" @click="openDetail(1)">Borrow</div>
            <div class="btn-2 btn-custom" @click="openDetail(2)">Farm</div>
            <div class="btn-3 btn-custom" @click="openDetail(3)">Return</div>
          </div>
        </Col>
      </Row>
    </content>
  </div>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'nuxt-property-decorator'
import { Menu, Row, Col, Icon } from 'ant-design-vue'
import { mapState } from 'vuex'
@Component({
  components: {
    Menu,
    Row,
    Col,
    Icon
  },
  computed: {
    ...mapState(['wallet'])
  }
})
export default class Nav extends Vue {
  pools = [
    {
      name: 'Yield Farming',
      value: '60%'
    },
    { name: 'Trading Fees', value: 'Data Unavailable' },
    { name: 'SPL Rewards', value: '-39.99%' },
    { name: 'Borrowing Interest', value: '59.00%' },
    { name: 'Total APR', value: '59.00%', className: 'green right' }
  ]

  openDetail(type: number) {
    this.$emit('openDetail', type)
  }
}
</script>

<style lang="less" scoped>
@import '../styles/variables';
.pools-wrap {
  width: 1200px;
  display: flex;
  flex-direction: column;
  height: 277px;
  padding: 30px;
  background: #fff;
  border-radius: 24px;
  nav {
    border-bottom: 1px solid #ddd;
  }
  .p_title1 {
    font-size: 24px;
    font-family: @fre-font;
  }
  .p_title {
    font-size: 18px;
    padding-bottom: 20px;
    line-height: 40px;
    color: @p-color;
  }
  content {
    background: #fff;
    border-radius: 24px;
    padding: 25px 0;
    .pool_col {
      font-size: 24px;
      color: @p-color;
      display: flex;
      align-items: center;
      justify-content: right;
      width: 100%;
      padding-left: 30px;
      .p_left {
        margin-right: 4px;
        width: 78px;
        position: relative;
        height: 48px;
        .img1 {
          width: 48px;
          position: absolute;
          left: 0;
          z-index: 1;
          top: 0;
        }
        .img2 {
          width: 48px;
          position: absolute;
          right: 0;
          z-index: 2;
          top: 0;
        }
      }
      .p_right {
        display: flex;
        flex-direction: column;
        margin-left: 18px;
        .p_text {
          display: flex;
          align-items: center;
          div {
            font-size: 24px;
            font-family: @fre-font;
            color: @p-color;
            margin-right: 8px;
          }
          span {
            width: 48px;
            height: 24px;
            border-radius: 6px;
            color: #fff;
            background: #ffa348;
            line-height: 24px;
            text-align: center;
            font-size: 16px;
            font-family: @fre-font;
          }
        }
        .p_tip {
          color: #7a736c;
          font-size: 12px;
          margin-top: 4px;
          font-weight: bold;
        }
        .p_prior {
          color: @s-color;
          font-size: 12px;
          margin-top: 4px;
          font-weight: bold;
        }
      }
    }
    .apy_col {
      display: flex;
      flex-direction: column;
      .span {
        font-size: 18px;
        color: #1eac49;
        font-family: @fre-font;
        margin-bottom: 8px;
      }
      .label {
        font-size: 12px;
        color: #7a736c;
        font-weight: bold;
        text-decoration: line-through;
      }
    }
    .yield_col {
      width: 100%;
    }
    .mult_col {
      font-size: 18px;
      font-family: @fre-font;
      color: @p-color;
      .mult_span {
        font-size: 18px;
        color: #f15726;
        font-family: @fre-font;
      }
    }
    .t_line {
      font-size: 14px;
      color: @p-color;
      font-family: @fre-font;
    }
    .btn_wrap {
      display: flex;
      flex-direction: column;
      padding-right: 30px;
      .btn {
        width: 120px;
        height: 36px;
        border-radius: 18px;
        line-height: 36px;
        color: #fff;
        font-size: 12px;
        display: block;
        text-align: center;
        background: @s-color;
        font-family: @fre-font;
        cursor: pointer;
      }
      .btn1 {
        margin-top: 12px;
        width: 120px;
        height: 36px;
        border-radius: 18px;
        line-height: 36px;
        color: #ffa348;
        font-size: 12px;
        text-align: center;
        border: 1px solid #ffa348;
        font-family: @fre-font;
        cursor: pointer;
      }
    }
  }
}

.pool_item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  > label {
    font-size: 12px;
    color: #7a736c;
    font-weight: bold;
  }
  .right {
    font-family: @fre-font;
    color: @p-color;
    font-size: 12px;
  }
}
.row {
  display: flex;
  align-items: center;
}
.btn-ops {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;

  .btn-custom {
    font-size: 12px;
    border-radius: 18px;
    font-family: @fre-font;
    width: 120px;
    height: 36px;
    text-align: center;
    line-height: 36px;
    cursor: pointer;
  }
  .btn-1 {
    border: 1px solid #f15726;
    color: #f15726;
  }
  .btn-2 {
    border: 1px solid #ffa348;
    color: #ffa348;
    margin-top: 12px;
  }
  .btn-3 {
    margin-top: 12px;
    border: 1px solid #aaa49f;
    color: #aaa49f;
  }
}
</style>
